package com.song.mapper;

import com.song.annotation.AutoFill;
import com.song.dto.EmployeeLoginDTO;
import com.song.dto.EmployeePageQueryDTO;
import com.song.dto.EmployeeRegisterDTO;
import com.song.entity.Employee;
import com.song.enumeration.SqlOperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface EmployeeMapper {

    //员工登录信息查询
    @Select("select * from employee where username=#{username}")
    Employee login(EmployeeLoginDTO employeeLoginDTO);

    //新增员工
    @AutoFill(SqlOperationType.INSERT)
    @Insert("insert into employee(username,name,password,phone,sex,id_number,status,create_time,update_time,create_user,update_user) values(#{username},#{name},#{password},#{phone},#{sex},#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void addEmployee(Employee  employee);

    // 分页查询员工
    List<Employee> getEmployeePage(EmployeePageQueryDTO employeePageQueryDTO);

    //更新员工账号信息
    @AutoFill(SqlOperationType.UPDATE)
    Integer updateEmployee(Employee  employee);

    //根据id查询员工信息
    @Select("select * from employee where id=#{id}")
    Employee getEmployeeById(Long id);
}
